<template>
    <div>
        <Card :bordered="false" style="background:#fff;width: 100%;">
            <p slot="title"> {{ data1[0].branch_zw + '_' + data1[0].floor_zw  +'_'+  data1[0].region_zw }} — 工位/办公室使用状态</p>


            <Table ref="table" :loading="loading" stripe :columns="columns1" :data="data1"></Table>

            <Page :total="total" :current="search.page" show-sizer show-total :page-size="search.rows" @on-page-size-change="getListByPageSize" @on-change="getListByPageNum"> </Page>

            <Button type="primary" class="closeBtn" @click="close">关闭</Button>
        </Card>
    </div>
</template>

<script>
    import {
        mapMutations
    } from 'vuex'
    import axios from '@/libs/api.request'
    export default {
        data() {
            return {

                loading: false,

                // 数据总条数
                total: 0,

                search: {
                    branchid: '',
                    floorid: '',
                    regionid: '',
                    cp_floorid: '',
                    cp_branchid: '',
                    cp_type: '',
                    page: 1,
                    rows: 10
                },
                columns1: [{
                        type: 'index',
                        align: 'center',
                        width: 60
                    },
                    {
                        title: '编号',
                        align: 'center',
                        key: 'number'
                    },
                    {
                        title: '使用状态',
                        align: 'center',
                        key: 'use_status_zw'
                    },
                    {
                        title: '人数',
                        align: 'center',
                        key: 'person_num'
                    },
                    {
                        title: '周末/节假日是否加班',
                        align: 'center',
                        key: 'is_holiday_work_zw'

                    },
                    {
                        title: '晚上是否加班',
                        align: 'center',
                        key: 'is_evening_work_zw'

                    },
                    {
                        title: '客户交流',
                        align: 'center',
                        key: 'ccids'
                    },
                    {
                        title: '备注',
                        align: 'center',
                        key: 'remark'
                    },

                ],
                data1: [{
                    branch_zw: '',
                    floor_zw: '',
                    region_zw: ''
                }]
            }
        },
        methods: {
            ...mapMutations(['myClose']),

            // 获取巡店工位列表
            getList() {
                this.loading = true
                let {
                    ...data
                } = this.search
                axios.ajax_post('admin-patrol_record-ajax_get_pr_ws', data).then(res => {
                    this.loading = false
                    if (res.data.code === 1) {
                        this.data1 = res.data.data.list
                        this.total = res.data.data.total_num

                        if (this.data1.length < 1 && this.total > 0) {
                            this.search.page = Math.ceil(this.total / this.search.rows)
                            this.getList()
                        }
                    } else {
                        this.$Notice.error({
                            title: res.data.msg,
                            duration: 3
                        })
                    }
                })
            },

            getListByPageSize(rows) {
                this.search.rows = rows
                this.getList()
            },

            getListByPageNum(page) {
                this.search.page = page
                this.getList()
            },

            // 关闭
            close() {
                this.myClose('workStationUseInfo')
            },
        },
        created() {
            this.search.branchid = this.$route.params.branchid
            this.search.floorid = this.$route.params.floorid
            this.search.regionid = this.$route.params.regionid
            this.search.cp_floorid = this.$route.params.cp_floorid
            this.search.cp_branchid = this.$route.params.cp_branchid
            this.search.cp_type = this.$route.params.cp_type
            this.getList()
        },
    }
</script>

<style lang='less' scoped>
    .cardBox {
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap
    }

    .card {
        width: 300px;
        height: 240px;
        color: #fff;
        background-color: #2BDE73;
        font-weight: 700;
        margin-right: 20px;

        &.empty {
            background-color: #2A7EFB;
        }

        &.not {
            background-color: #FF9905;
        }

        &.noShop {
            background-color: #cccccc;
        }

        .title {
            color: #fff;
            font-size: 16px;
        }

        .cardBody {
            header {
                margin-bottom: 10px;
            }

            main {
                margin-bottom: 15px;

                p {
                    line-height: 23px;
                }
            }

            footer {
                position: absolute;
                bottom: 8px;
            }
        }

        .flag {
            position: absolute;
            width: 48px;
            height: 48px;
            bottom: 5px;
            right: 12px;
        }

        .expire {
            width: 100px;
            height: 100px;
            position: absolute;
            bottom: 0;
            right: 0;

            img {
                width: 100px;
                height: 100px;
            }

            p {
                position: absolute;
                right: 8px;
                bottom: 40px;
            }

            span {
                position: absolute;
                right: 5px;
                bottom: 5px;
                font-size: 22px;

            }
        }
    }

    .closeBtn {
        width: 100px;
        display: block;
        margin: 60px auto;
    }
</style>